{template 'header'}
<link href="./resource/css/app.css" rel="stylesheet">
<ul class="nav nav-tabs">
    <li class=""><a href="{php echo $this->createWeburl('order');}">订单管理</a></li>
    <li class="active"><a href="{php echo $this->createWeburl('integralOrder');}">积分订单管理</a></li>
</ul>
<form action="./index.php" method="get" class="form-horizontal">
    <input type="hidden" name="c" value="site">
    <input type="hidden" name="a" value="entry">
    <input type="hidden" name="m" value="bh_bargain">
    <input type="hidden" name="do" value="integralOrder">
    <div class="form-group">
        <label class="col-xs-12 col-sm-1 control-label">用户昵称</label>
        <div class="col-sm-2 col-xs-12">
            <input type="text" class="form-control" name="nickname"  value="{$nickname}" />
        </div>
        <label class="col-xs-12 col-sm-1 control-label">状态类型</label>
        <div class="col-sm-2 col-xs-12">
            <select name="type" class="col-sm-10">
                <option value="0" >所有</option>
                <option {if $type == 1} selected="selected" {/if} value="1">实物</option>
                <option {if $type == 2} selected="selected" {/if} value="2">拼多多</option>
            </select>
        </div>
        <div class="col-xs-12 col-sm-2 col-md-2 col-lg-2">
            <button type="submit" class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
        </div>
    </div>
</form>
<div class="panel panel-default">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th style="width:80px;">id</th>
                <th style="width:80px;">昵称</th>
                <th style="width:80px;">商品</th>
                <th style="width:80px;">兑换方式</th>
                <th style="width:80px;">积分</th>
                <th style="width:80px;">金额</th>
                <th style="width:80px;">是否支付</th>
                <th style="width:80px;">状态</th>
                <th style="width:70px;">快递公司</th>
                <th style="width:85px;">快递单号</th>
                <th style="width:85px;">地址</th>
                <th style="width:60px;">发货时间</th>
                <th style="width:60px;">姓名</th>
                <th style="width:60px;">电话</th>
                <th style="width:80px;">操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $list $k}
            <tr>
                <td>{$k['id']}</td>
                <td>{$k['member']['nickname']}</td>
                <td>{$k['goods_name']}</td>
                <td>{php echo $k['exchange_type'] ==1 ? "积分" : "积分加钱" }</td>
                <td>{$k['exchange_number']}</td>
                <td>{$k['money']}</td>
                <td>{php echo $k['is_pay'] ==1 ? '未发起' : '发起'}</td>
                <td>{$k['state']}</td>
                <td>{$k['courier_name']}</td>
                <td>{$k['courier_number']}</td>
                <td>{$k['address']}</td>
                <td>{php echo date('Y-m-d H:i:s', $k['delivery_time'])}</td>
                <td>{$k['name']}</td>
                <td>{$k['phone']}</td>
                <td>
                    {if $k['status'] == 1}
                    <a class="btn btn-success btn-sm" href="{php echo $this->createWeburl('integralOrder', array('op' => 'editshow', 'id' => $k['id']));}" data-id="{$k['id']}" >发货</a>
                    {elseif $k['status']==2 }
                    <a href="javascript:;" data-id="{$k['id']}" class="success btn btn-warning  btn-sm">完成</a>
                    <a href="javascript:;" data-id="{$k['id']}" class="cancel btn btn-danger  btn-sm">取消</a>
                    {elseif $k['status'] ==3}
                    <a href="javascript:;" data-id="{$k['id']}" class=" btn btn-warning  btn-sm">已完成</a>
                    {else}
                    <a href="javascript:;" data-id="{$k['id']}" class=" btn btn-danger  btn-sm">已取消</a>
                    {/if}
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
    </div>
    <div class="ding" style="text-align: left; margin-left: 16px;">
        总订单量:<span style="color: red">{php echo $total ? : 0}</span>,
        今日订单量<span style="color: red">{php echo $todayOrder ? : 0}</span>
        完成订单量<span style="color: red">{php echo $orderSucess ? : 0}</span>
    </div>
    {$pager}
</div>
<script type="application/javascript">
    $(function () {
        $('.success').click(function () {
            if (!confirm('确定该笔订单已完成')) {
                return false;
            }
            id = $(this).data('id');
            $.post('', {id:id, op:'success'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('完成错误');
                }

            }, 'json')
        });


        $('.cancel').click(function () {
            if (!confirm('确定取消订单已完成')) {
                return false;
            }
            var  id = $(this).data('id');
            $.post('', {id:id, op:'cancel'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('取消失败');
                }

            }, 'json')
        });
    });

</script>